<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" href="css/style.css" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
		<script type="text/javascript">
			function onLogin() {
				var username = document.getElementById("username").value;
				var password = document.getElementById("password").value;
				if (username.length == 0 || password.length == 0){
					alert("输入不能为空！");
				} else {
					$.ajax({
						url: "https://dlnu-ljq.cn.utools.club/users/login",
						type: "post",
						dataType: "json",
						contentType: 'application/json',
						data: JSON.stringify({
							sno: username,
							password: password
						}),
						crossDomain: true,
						asyn: "false",
						success: function(res){
							console.log(res);
							alert("登陆成功");
							window.location.href='student.html?userId=' + res.data.userId;
						}
					})		
				}
			}
		</script>
		<title>登录界面</title>
	</head>
	<body>
		<div id="bigBox">
			<h1>选课系统</h1>
			<div class="inputBox">
				<div class="inputText">
					<span class="iconfont icon-nickname"></span>
					<input id="username" type="text" placeholder="Username" />
				</div>
				<div class="inputText">
					<span class="iconfont icon-visible"></span>
					<input id="password" type="password" placeholder="Password" />
				</div>
			</div>
			<input class="loginButton" type="button" value="Login" onclick="onLogin()"/>
		</div>
	</body>
</html>
